package com.ruoyi.web.controller.work;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.flowable.api.domain.WorkSignFile;
import com.ruoyi.work.service.IWorkSignFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 签署文件Controller
 *
 * @author fengcheng
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/work/signFile")
public class WorkSignFileController extends BaseController {
    @Autowired
    private IWorkSignFileService workSignFileService;


    /**
     * 获取盖章主文件详细信息
     *
     * @param signId
     * @return
     */
    @GetMapping("/getInfoWorkSignFile/{signId}")
    public AjaxResult getInfoWorkSignFile(@NotNull(message = "signId为空") @PathVariable("signId") Long signId) throws Exception {
        return success(workSignFileService.getInfoWorkSignFile(signId));
    }

    /**
     * 查询签署文件列表
     *
     * @param signId
     * @return
     */
    @GetMapping("/listWorkSignFileList/{signId}")
    public AjaxResult listWorkSignFileList(@NotNull(message = "signId为空") @PathVariable("signId") Long signId) throws Exception {
        WorkSignFile workSignFile = new WorkSignFile();
        workSignFile.setSignId(signId);
        return success(workSignFileService.selectWorkSignFileList(workSignFile));
    }

    /**
     * 查询签署文件列表
     */
    @PreAuthorize("@ss.hasPermi('work:signFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkSignFile workSignFile) {
        startPage();
        List<WorkSignFile> list = workSignFileService.selectWorkSignFileList(workSignFile);
        return getDataTable(list);
    }

    /**
     * 获取签署文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:signFile:query')")
    @GetMapping(value = "/{signFileId}")
    public AjaxResult getInfo(@PathVariable("signFileId") Long signFileId) {
        return success(workSignFileService.selectWorkSignFileBySignFileId(signFileId));
    }
}
